/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.animation.transformations;

import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.api.Generator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.TransformGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.TransformParamChecker;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.transformations.Rotation;
import pl.edu.amu.wmi.kino.visualjavafx.model.objects.VisualObject;

/**
 *
 * @author Admin
 */
public class RotationGenerator implements Generator {
    
    @Override
    public boolean canGenerate(Object c) {
        if(c instanceof Rotation)
            return true;
        else return false;
    }

    @Override
    public void generate(StringBuilder sb, Object o,int recursionLevel,Object original) {
        this.generateAngle(sb,(Rotation)o,recursionLevel);
        this.generateAnchorX(sb, (Rotation)o,recursionLevel,original);
        this.generateAnchorY(sb, (Rotation)o,recursionLevel,original);
    }

    private void generateAngle(StringBuilder sb,Rotation r,int recursionLevel){

        if(TransformParamChecker.generateParam(r.getDestinedRotationAngle()))
            sb.append(TransformGenerator.angle+recursionLevel +" => "+r.getDestinedRotationAngle()+" tween Interpolator."+
                r.getInterpolations()[0].getName()+",\n");
    }
    
    private void generateAnchorX(StringBuilder sb,Rotation r,int recursionLevel,Object original){

        VisualObject v = (VisualObject)original;
        if(TransformParamChecker.generateParam(r.getDestinedHcenter()))
            sb.append(TransformGenerator.anchorX+recursionLevel +" => "
                    +(r.getDestinedHcenter()+v.getHPos())+" tween Interpolator."+
                r.getInterpolations()[1].getName()+",\n");
    }

    private void generateAnchorY(StringBuilder sb,Rotation r,int recursionLevel,Object original){
        VisualObject v = (VisualObject)original;
        if(TransformParamChecker.generateParam(r.getDestinedVCenter()))
            sb.append(TransformGenerator.anchorY+recursionLevel +" => "
                    +(r.getDestinedVCenter()+v.getVPos())+" tween Interpolator."+
                r.getInterpolations()[2].getName()+",\n");
    }

}
